import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';


void main()=>runApp(
    MaterialApp(
      home: Scaffold(
        body: MyApp(),
      ),
      theme: ThemeData(
        primarySwatch: Colors.yellow,
        textTheme: TextTheme(),
        buttonTheme: ButtonThemeData(buttonColor: Colors.yellow),
      ),
    )
);

class MyApp extends StatefulWidget {

  @override
  State<StatefulWidget> createState() {
    return _MyAppState();
  }

}

class _MyAppState extends State<MyApp> {

  @override
  Widget build(BuildContext context) {
    Widget avatar = Image.network("https://img1.baidu.com/it/u=3435361414,3054623528&fm=253&fmt=auto&app=138&f=JPEG?w=224&h=322",
        width: 120.0, height: 120.0,fit: BoxFit.fitWidth,);
    return SingleChildScrollView(
        child: Padding(
          padding: EdgeInsets.fromLTRB(0,MediaQuery.of(context).padding.top,0,0),
          child: Column(
            children: <Widget>[
              DecoratedBox(
                  decoration: BoxDecoration(
                      gradient: LinearGradient(colors:[Colors.red,Colors.orange.shade700]), //背景渐变
                      borderRadius: BorderRadius.circular(3.0), //3像素圆角
                      boxShadow: [ //阴影
                        BoxShadow(
                            color:Colors.black54,
                            offset: Offset(2.0,2.0),
                            blurRadius: 4.0
                        )
                      ]
                  ),
                  child: Padding(
                    padding: EdgeInsets.symmetric(horizontal: 80.0, vertical: 18.0),
                    child: Text("Login", style: TextStyle(color: Colors.white),),
                  )
              ),
              avatar, //不剪裁
              ClipOval(child: avatar), //剪裁为圆形
              ClipRRect( //剪裁为圆角矩形
                borderRadius: BorderRadius.circular(5.0),
                child: avatar,
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Align(
                    alignment: Alignment.topLeft,
                    widthFactor: .5,//宽度设为原来宽度一半，另一半会溢出
                    child: avatar,
                  ),
                  Text("你好世界", style: TextStyle(color: Colors.green),)
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  ClipRect(//将溢出部分剪裁
                    child: Align(
                      alignment: Alignment.topLeft,
                      widthFactor: .5,//宽度设为原来宽度一半
                      child: avatar,
                    ),
                  ),
                  Text("你好世界",style: TextStyle(color: Colors.green))
                ],
              ),
            ],
          ),
        )
    );
  }

}







